<?php
namespace common\sources\write\loginrole;

use \common\models\craftsman\LoginRole;

class LoginRoleAccess implements ILoginRoleAccess
{
    //添加新角色
    public function addRole($data)
    {
        $newRole = new LoginRole();
        $newRole->powerid = $data['powerids'];
        $newRole->role_name = $data['rolename'];
        $newRole->description = $data['description'];
        if (!$newRole->save()) {
            return false;
        }
        return true;
    }

	//编辑操作
	public function editRole($data) {
		return LoginRole::updateAll([
			'powerid'     => $data['powerids'],
			'role_name'   => $data['rolename'],
			'description' => $data['description']
		], ['roleid' => $data['role_id']]);
	}
}